home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 3382 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  882 b 

  1. Path: mail2news.demon.co.uk!gate.demon.co.uk
  2. From: "Paul F. Robinson" <pfr@doodey.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Checking to See if a File Exists
  5. Date: Sun, 28 Jan 96 14:12:53 GMT
  6. Organization: Private node
  7. Message-ID: <9601281412.AA0001c@doodey.demon.co.uk>
  8. References: <DLtI7G.HpE@midway.uchicago.edu>
  9. X-NNTP-Posting-Host: gate.demon.co.uk
  10. X-Newsreader: TIN [AMIGA 1.3 950726BETA PL0]
  11. X-Mail2News-Path: relay-1.mail.demon.net!gate.demon.co.uk
  12.  
  13. josef jurek (jaj3@kimbark.uchicago.edu) wrote:
  14. : How does one check from a C program to see whether a file
  15. : exists or not?
  16.  
  17. Your compiler library might have an  access()  function.
  18. Alternatively,
  19. attempt to open the file with fopen().
  20. If successful, the file exists. -Don't forget to fclose() it.
  21. If unsuccessful, check the value of errno. ENOENT (from errno.h)
  22.  indicates that the file does not exist.
  23.  
  24. Paul.
  25.  
  26.